/**
 * 模块：医院入驻平台-SysCodeType
 */
package design.onekey.controller;

import design.onekey.annotation.Check;
import design.onekey.annotation.LoginUser;
import design.onekey.base.BaseEntity;
import design.onekey.base.Response;
import design.onekey.model.dto.UserInfoDto;
import design.onekey.model.SysCodeType;
import design.onekey.service.ISysCodeTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @Description: SysCodeTypecontroller类
* @author
* @date 2020-06-05 04:02:20
* @version V1.0
*/
@RestController
@RequestMapping("/api/sysCodeType")
public class SysCodeTypeController extends BaseController {

   /**
    * iSysCodeTypeService服务注入
    */
   @Autowired
   private ISysCodeTypeService iSysCodeTypeService;

   /**
   * @Description: 分页查询表格
   * @param SysCodeType
   * @param @return
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/getTableList",method = RequestMethod.POST)
   public Response getTableList(@RequestBody SysCodeType model)
   {

       BaseEntity result = new BaseEntity();
       result = iSysCodeTypeService.tablePagingQuery(model);
       return Response.success(result);
   }

   /**
   * @Description: 获取详细信息
   * @param id
   * @param @return  BaseEntity
   * @return
   * @throws
   */
   @RequestMapping(value = "/getDetail",method = RequestMethod.GET)
   @Check({"id:required#主键ID"})
   public Response getDetail(@RequestParam Long id) throws Exception
   {
       BaseEntity result = iSysCodeTypeService.getDetail(id);
       return Response.success(result);
   }

   /**
   * @throws Exception
   * @Description: 新增
   * @param SysCodeType
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/insert",method = RequestMethod.POST)
   @Check({"codeType:required#字典类别代码;length#字典类别代码#30","codeTypeName:required#字典类别名称;length#字典类别名称#50","codeDesc:length#字典描述#100",})
//   @NoRepeatSubmit
   public Response insert(@RequestBody SysCodeType model, @LoginUser UserInfoDto userInfoDto) throws Exception
   {
       BaseEntity result = iSysCodeTypeService.insert(model,userInfoDto);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @throws Exception
   * @Description: 更新
   * @param SysCodeType
   * @return  BaseEntity
   * @throws
   */
   @RequestMapping(value = "/update",method = RequestMethod.POST)
   @Check({"id:required#主键ID","codeType:required#字典类别代码;length#字典类别代码#30","codeTypeName:required#字典类别名称;length#字典类别名称#50","codeDesc:length#字典描述#100",})
//   @NoRepeatSubmit
   public Response update(@RequestBody SysCodeType model, @LoginUser UserInfoDto userInfoDto) throws Exception
   {
       BaseEntity result = iSysCodeTypeService.update(model,userInfoDto);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @Description: 单条删除
   * @param id
   * @return  BaseEntity
   * @throws
   */
   @RequestMapping(value = "/delete",method = RequestMethod.GET)
   @Check({"id:required#主键ID"})
   public Response delete(@RequestParam Long id)
   {
       BaseEntity result = iSysCodeTypeService.delete(id);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @Description: 批量删除
   * @param SysCodeType
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/deletebatch",method = RequestMethod.POST)
   public Response deletebatch(@RequestBody List<Long> ids)
   {
       BaseEntity result = iSysCodeTypeService.deleteBatch(ids);
       return Response.success(result.getStatusMsg());
   }
}
